<?php

namespace app\modules\api\controllers;

use Yii;
use yii\rest\ActiveController;

/**
 * @OA\Tag(
 *   name="Item",
 *   description="权限项管理",
 * )
 */
class ItemController extends ActiveController
{
    public $modelClass = 'app\modules\api\models\Item';

    /**
     * @OA\Get(
     *      path="/item",
     *      summary="权限项列表树",
     *      tags={"Item"},
     *      @OA\Parameter(
     *          description="上级Id",
     *          in="query",
     *          name="parentId",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="itemTop",
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="id", type="integer", example="1", description="权限项id"),
     *                          @OA\Property(property="name", type="string", example="客户管理", description="权限项名称"),
     *                      ),
     *                  ),
     *                  @OA\Property(
     *                      property="item",
     *                      type="array",
     *                      @OA\Items(
     *                          type="object",
     *                          @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                          @OA\Property(property="pid", type="integer", example=1, description="上级ID"),
     *                          @OA\Property(property="status", type="integer", example=1, description="状态"),
     *                          @OA\Property(property="label", type="string", example="客户管理", description="权限项名称"),
     *                          @OA\Property(property="userCount", type="integer", example=1554, description="用户数统计"),
     *                          @OA\Property(property="roleCount", type="integer", example=1568, description="角色数统计"),
     *                          @OA\Property(
     *                              property="children",
     *                              type="array",
     *                              @OA\Items(
     *                                  type="object",
     *                                  @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                                  @OA\Property(property="pid", type="integer", example=1, description="上级ID"),
     *                                  @OA\Property(property="status", type="integer", example=1, description="状态"),
     *                                  @OA\Property(property="label", type="string", example="客户", description="权限项名称"),
     *                                  @OA\Property(property="userCount", type="integer", example=894, description="用户数统计"),
     *                                  @OA\Property(property="roleCount", type="integer", example=662, description="角色数统计"),
     *                                  @OA\Property(
     *                                      property="children",
     *                                      type="array",
     *                                      @OA\Items(
     *                                          @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                                          @OA\Property(property="pid", type="integer", example=1, description="上级ID"),
     *                                          @OA\Property(property="status", type="integer", example=1, description="状态"),
     *                                          @OA\Property(property="label", type="string", example="列表", description="权限项名称"),
     *                                          @OA\Property(property="userCount", type="integer", example=342, description="用户数统计"),
     *                                          @OA\Property(property="roleCount", type="integer", example=456, description="角色数统计"),
     *                                          @OA\Property(
     *                                             property="children",
     *                                             type="array",
     *                                             @OA\Items()
     *                                          )
     *                                      )
     *                                  )
     *                              )
     *                          )
     *                      ),
     *                  )
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionIndex()
    {
    }

    /**
     * @OA\Post(
     *      path="/item/create",
     *      tags={"Item"},
     *      summary="添加权限项",
     *      @OA\RequestBody(
     *          @OA\MediaType(
     *              mediaType="multipart/form-data",
     *              @OA\Schema(
     *                  required={"name", "route", "dataAuth"},
     *                  @OA\Property(property="parentId", type="integer", description="上级ID"),
     *                  @OA\Property(property="name", type="string", description="权限项名称"),
     *                  @OA\Property(property="route", type="string", description="路由地址"),
     *                  @OA\Property(property="dataAuth", type="integer", enum={0, 1, 2}, description="数据授权（ 0：不需要、1：需要、2：字段授权 ）", default=0),
     *                  @OA\Property(property="remark", type="string", description="备注", default=""),
     *             )
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionCreate()
    {
    }

    /**
     * @OA\Post(
     *      path="/item/update",
     *      tags={"Item"},
     *      summary="编辑权限项",
     *      @OA\Parameter(
     *          name="id",
     *          in="query",
     *          description="权限项ID",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *          ),
     *      ),
     *      @OA\RequestBody(
     *          @OA\MediaType(
     *              mediaType="multipart/form-data",
     *              @OA\Schema(
     *                  required={"name", "route", "dataAuth"},
     *                  @OA\Property(property="parentId", type="integer", description="上级ID"),
     *                  @OA\Property(property="name", type="string", description="权限项名称"),
     *                  @OA\Property(property="route", type="string", description="路由地址"),
     *                  @OA\Property(property="dataAuth", type="integer", enum={0, 1, 2}, description="数据授权（ 0：不需要、1：需要、2：字段授权 ）", default=0),
     *                  @OA\Property(property="remark", type="string", description="备注", default=""),
     *             )
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionUpdate()
    {
    }

    /**
     * @OA\Post(
     *      path="/item/delete",
     *      summary="删除权限项",
     *      tags={"Item"},
     *      @OA\Parameter(
     *          description="权限项ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionDelete()
    {
    }

    /**
     * @OA\Post(
     *      path="/item/enable",
     *      summary="启用权限项",
     *      tags={"Item"},
     *      @OA\Parameter(
     *          description="权限项ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionEnable()
    {

    }

    /**
     * @OA\Post(
     *      path="/item/disable",
     *      summary="禁用权限项",
     *      tags={"Item"},
     *      @OA\Parameter(
     *          description="权限项ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionDisable()
    {

    }

    /**
     * @OA\Get(
     *      path="/item/get-user",
     *      summary="权限项 所属个人",
     *      tags={"Item"},
     *      @OA\Parameter(
     *          description="权限项ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Parameter(
     *          description="权限项名称",
     *          in="query",
     *          name="name",
     *          @OA\Schema(
     *              type="string",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Parameter(
     *          description="页数",
     *          in="query",
     *          name="page",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Parameter(
     *          description="每页数量",
     *          in="query",
     *          name="pageSize",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="user",
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="id", type="integer", example="1", description="用户ID"),
     *                          @OA\Property(property="name", type="string", example="张三", description="用户姓名"),
     *                          @OA\Property(property="author", type="string", example="admin", description="创建人"),
     *                          @OA\Property(property="createdAt", type="integer", example="2020-06-22 10:39:47", description="创建时间"),
     *                      ),
     *                  ),
     *                  @OA\Property(property="totalCount", type="integer", example="30", description="角色总数"),
     *                  @OA\Property(property="pageSize", type="integer", example="15", description="每页数量"),
     *                  @OA\Property(property="page", type="integer", example="2", description="总页数")
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionGetUser()
    {
    }

    /**
     * @OA\Post(
     *      path="/item/remove-user",
     *      summary="移除权限项下的用户",
     *      tags={"Item"},
     *      @OA\Parameter(
     *          description="权限项ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\RequestBody(
     *          @OA\MediaType(
     *              mediaType="multipart/form-data",
     *              @OA\Schema(
     *                  required={"userId[]"},
     *                  @OA\Property(
     *                      property="userId[]",
     *                      type="array",
     *                      description="用户ids",
     *                      @OA\Items(type="integer")
     *                  ),
     *             )
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionRemoveUser()
    {
    }

    /**
     * @OA\Get(
     *      path="/item/get-role",
     *      summary="权限项 所属角色",
     *      tags={"Item"},
     *      @OA\Parameter(
     *          description="权限项ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Parameter(
     *          description="权限项名称",
     *          in="query",
     *          name="name",
     *          @OA\Schema(
     *              type="string",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Parameter(
     *          description="页数",
     *          in="query",
     *          name="page",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Parameter(
     *          description="每页数量",
     *          in="query",
     *          name="pageSize",
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="user",
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="id", type="integer", example="1", description="用户ID"),
     *                          @OA\Property(property="name", type="string", example="营养师", description="角色姓名"),
     *                          @OA\Property(property="author", type="string", example="admin", description="创建人"),
     *                          @OA\Property(property="createdAt", type="integer", example="2020-06-22 10:39:47", description="创建时间"),
     *                      ),
     *                  ),
     *                  @OA\Property(property="totalCount", type="integer", example="30", description="角色总数"),
     *                  @OA\Property(property="pageSize", type="integer", example="15", description="每页数量"),
     *                  @OA\Property(property="page", type="integer", example="2", description="总页数")
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionGetRole()
    {
    }

    /**
     * @OA\Post(
     *      path="/item/remove-role",
     *      summary="移除权限项下的角色",
     *      tags={"Item"},
     *      @OA\Parameter(
     *          description="权限项ID",
     *          in="query",
     *          name="id",
     *          required=true,
     *          @OA\Schema(
     *              type="integer",
     *              format="int32"
     *          )
     *      ),
     *      @OA\RequestBody(
     *          @OA\MediaType(
     *              mediaType="multipart/form-data",
     *              @OA\Schema(
     *                  required={"roleId[]"},
     *                  @OA\Property(
     *                      property="roleId[]",
     *                      type="array",
     *                      description="角色ids",
     *                      @OA\Items(type="integer")
     *                  ),
     *             )
     *          )
     *      ),
     *      @OA\Response(
     *          response=200,
     *          description="操作成功"
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionRemoveRole()
    {
    }

    /**
     * @OA\Get(
     *      path="/item/get-param",
     *      summary="权限项下拉列表数据",
     *      tags={"Item"},
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="label", type="string", example="客户管理", description="权限项名称"),
     *                          @OA\Property(property="value", type="integer", example=1, description="权限项ID"),
     *                      ),
     *                  ),
     *                  example={"label":"客户管理", "value": 1}
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionGetParam()
    {
    }

    /**
     * @OA\Get(
     *      path="/item/get-list",
     *      summary="权限项 列表数据 + 数据授权类型",
     *      tags={"Item"},
     *      @OA\Response(
     *          response=200,
     *          description="操作成功",
     *          @OA\MediaType(
     *              mediaType="application/json",
     *              @OA\Schema(
     *                  @OA\Property(
     *                      property="typeList",
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="label", type="string", example="自己和下属", description="数据授权类型"),
     *                          @OA\Property(property="value", type="integer", example=1, description="值"),
     *                      ),
     *                  ),
     *                  @OA\Property(
     *                      property="authList",
     *                      type="array",
     *                      @OA\Items(
     *                          @OA\Property(property="label", type="string", example="读写", description="字段授权类型"),
     *                          @OA\Property(property="value", type="integer", example=1, description="值"),
     *                      ),
     *                  ),
     *                  @OA\Property(
     *                      property="item",
     *                      type="array",
     *                      @OA\Items(
     *                          type="object",
     *                          @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                          @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                          @OA\Property(property="name", type="string", example="客户管理", description="权限项名称"),
     *                          @OA\Property(property="auth", type="integer", example=0, description="数据授权（ 0：不需要、1：需要、2：字段授权）"),
     *                          @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                          @OA\Property(
     *                              property="children",
     *                              type="array",
     *                              @OA\Items(
     *                                  type="object",
     *                                  @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                                  @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                                  @OA\Property(property="name", type="string", example="客户", description="权限项名称"),
     *                                  @OA\Property(property="auth", type="integer", example=0, description="数据授权（ 0：不需要、1：需要、2：字段授权）"),
     *                                  @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                                  @OA\Property(
     *                                      property="children",
     *                                      type="array",
     *                                      @OA\Items(
     *                                          @OA\Property(property="id", type="integer", example=1, description="权限项ID"),
     *                                          @OA\Property(property="pid", type="integer", example=0, description="上级ID"),
     *                                          @OA\Property(property="name", type="string", example="列表", description="权限项名称"),
     *                                          @OA\Property(property="auth", type="integer", example=0, description="数据授权（ 0：不需要、1：需要、2：字段授权）"),
     *                                          @OA\Property(property="status", type="integer", example=0, description="状态（ 0：禁用、1：启用 ）"),
     *                                          @OA\Property(
     *                                             property="children",
     *                                             type="array",
     *                                             @OA\Items()
     *                                          )
     *                                      )
     *                                  )
     *                              )
     *                          )
     *                      )
     *                  )
     *              )
     *          )
     *      ),
     *      security={{
     *          "ApiKeyAuth":{}
     *      }}
     * )
     */
    public function actionGetList()
    {
    }
}
